package sein.android.hopenote;

import java.util.ArrayList;

import android.R.string;
import android.app.ActivityGroup;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import sein.android.hopenote.Note_Add;

public class Note_Input_Tab extends ActivityGroup {
	public static Note_Input_Tab InputTabGroup;
	private ArrayList<View> history;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		history = new ArrayList<View>();
		InputTabGroup = this;

		Intent intent = new Intent(Note_Input_Tab.this, Note_Input.class);
		View view = getLocalActivityManager().startActivity(
				"Note_input",
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
						| Intent.FLAG_ACTIVITY_SINGLE_TOP)).getDecorView();

		replaceView(view, "note_input");
		// replaceView(view,"note_add");
	}

	// 새로운 Level의 Activity를 추가하는 경우
	public void replaceView(View view, String pageid) {
		history.add(view);
		setContentView(view);
	}

	// Back Key가 눌러졌을 경우에 대한 처리
	public void back() {
		if (history.size() > 0) {
			history.remove(history.size() - 1);
			if (history.size() == 0)
				finish();
			else {
				setContentView(history.get(history.size() - 1));
			}
		} else {
			finish();
		}
	}

	// Back Key에 대한 Event Handler
	@Override
	public void onBackPressed() {
		InputTabGroup.back();
		return;
	}

}
